package com.zrf.testchatgpt.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zrf.testchatgpt.entity.Permission;
import com.zrf.testchatgpt.entity.Role;
import com.zrf.testchatgpt.util.Result;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Component;

import java.security.PublicKey;
import java.util.List;

public interface PermissionMapper extends BaseMapper<Permission> {

    public List<Permission> queryByRoleId(Integer userid);
    public int updatePermissionById(@Param("userId") String userId,@Param("list") List<Integer> list);
    public int deletePermissionById(@Param("userId") String userId,@Param("list") List<Integer> list);
    @Select("SELECT  permission_id from role_permission where role_id=#{roleId}")
    public List<Integer> getPermissionByRoleId(String roleId);
    @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
    @Insert("insert into permission(permission_name,resource,sn) values(#{permission.permissionName},#{permission.resource},#{permission.sn})")
    public Integer Myinsert(@Param("permission") Permission permission);
    @Select("select permission_id from user_permission where user_id=#{userId}" )
    public List<Integer> getPermissionByUserId(String userId);
}
